| Concept | Parent Class, Child Class, or Interface? |
|---|---|
| Goods | Parent Class |
| Food | Child Class |
| Toy | Child Class |
| Book | Child Class |
| Taxable | Interface |
Here is a picture that shows the classes and the interface. The children classes extend their parent. This is shown with a solid arrow pointing at the parent.
The solid arrows show inheritance.
The three children inherit the display() method.
Two of the classes implement the interface. This is shown with a dotted arrow pointing at the interface.
The dotted arrow show what a class must implement.
The Toy and Book
classes must implement the calculateTax() method.